The red points represent the observed target proportions of Rx opioids from CIHI report, the blue points represent an annual average (weighted by population during that month), the other coloured points represent monthly prevalence predicted from the model
Code
p2 <-ggplot() +geom_point(data = prop_opioids_rx_uncalib_wei_mean,aes(x = year, y = target_val, color =factor(grp),fill =factor(grp))) +xlab("Year") +ylab("Prevalence of prescription opioid use")+scale_color_brewer(palette ="Dark2", name ="") +scale_fill_brewer(palette ="Dark2", name ="")plotly::ggplotly(p2)
2 Deaths and OD-Deaths
Code
################ Deaths # number of deathsv_yr1_deaths <-c(2016:2020)yrs_deaths <-length(v_yr1_deaths)num_deaths_uncalib <-rep(NA, yrs_deaths)for (i in1:yrs_deaths){ yr <- (v_yr1_deaths[1] -1) + i num_deaths_uncalib[i] <- mod_basecase$m_M[year_mon_cycle_tbl$cycle[year_mon_cycle_tbl$year == yr & year_mon_cycle_tbl$mon ==12] +1,"BO_DEATH"] - mod_basecase$m_M[year_mon_cycle_tbl$cycle[year_mon_cycle_tbl$year == yr -1& year_mon_cycle_tbl$mon ==12] +1,"BO_DEATH"] }# number of OD-deathsv_yr1_oddeaths <-c(2016:2021)yrs_oddeaths <-length(v_yr1_oddeaths)num_od_deaths_uncalib <-rep(NA, yrs_oddeaths)for (i in1:yrs_oddeaths){ yr <- (v_yr1_oddeaths[1] -1) + i num_od_deaths_uncalib[i] <- mod_basecase$m_M[year_mon_cycle_tbl$cycle[year_mon_cycle_tbl$year == yr & year_mon_cycle_tbl$mon ==12] +1,"BO_OD_DEATH"] - mod_basecase$m_M[year_mon_cycle_tbl$cycle[year_mon_cycle_tbl$year == yr -1& year_mon_cycle_tbl$mon ==12] +1,"BO_OD_DEATH"]}deaths_target_uncalib_tbl <- calib_target_tbl %>%select(year, target, group) %>%rename(target_val = target,target = group) %>%filter(target %in%c("total_deaths", "total_od_deaths")) %>%mutate(target =ifelse(target =="total_deaths", "Total deaths",ifelse(target =="total_od_deaths","Total opioid-related overdose deaths", NA)),group ="Target") %>%bind_rows(., data.frame(target_val = num_deaths_uncalib) %>%mutate(target ="Total deaths") %>%bind_rows(., data.frame(target_val = num_od_deaths_uncalib) %>%mutate(target ="Total opioid-related overdose deaths")) %>%mutate(year =c(v_yr1_deaths, v_yr1_oddeaths),group ="Model"))p3 <-ggplot() +geom_point(data = deaths_target_uncalib_tbl,aes(x = year, y = target_val, color =factor(group),fill =factor(group))) +xlab("Year") +ylab("Total Deaths") +scale_color_brewer(palette ="Dark2", name ="") +scale_fill_brewer(palette ="Dark2", name ="") +facet_wrap(~target, scales ="free") +theme(legend.position="bottom")plotly::ggplotly(p3)
Code
plotly::ggplotly(ggplot() +geom_point(data = deaths_target_uncalib_tbl %>%filter(target =="Total deaths"),aes(x = year, y = target_val, color =factor(group),fill =factor(group))) +xlab("Year") +ylab("Total Deaths") +scale_color_brewer(palette ="Dark2", name ="") +scale_fill_brewer(palette ="Dark2", name =""))
Code
# facet_wrap(~target, scales = "free") + theme(legend.position="bottom")plotly::ggplotly(ggplot() +geom_point(data = deaths_target_uncalib_tbl %>%filter(target =="Total opioid-related overdose deaths"),aes(x = year, y = target_val, color =factor(group),fill =factor(group))) +xlab("Year") +ylab("Total opioid-related overdose deaths") +scale_color_brewer(palette ="Dark2", name ="") +scale_fill_brewer(palette ="Dark2", name =""))
3 OAT
Code
# number of oatv_yr1_oat <-c(2018:2021)yrs_oat <-length(v_yr1_oat)num_oat_uncalib <-rep(NA, yrs_oat)for (i in1:yrs_oat){ yr <- (v_yr1_oat -1) + i num_oat_uncalib[i] <-sum(mod_basecase$m_M[year_mon_cycle_tbl$cycle[year_mon_cycle_tbl$year == yr & year_mon_cycle_tbl$mon ==6] +1,c("BS_OAT_INI", "BS_OAT_MAINT", "BR_OAT_INI", "BR_OAT_MAINT")])}oat_target_uncalib_tbl <- calib_target_tbl %>%select(year, target, group) %>%rename(target_val = target,target = group) %>%filter(target %in%"total_oat") %>%mutate(target =ifelse(target =="total_oat","Total OAT", NA),group ="Target") %>%bind_rows(., data.frame(target_val = num_oat_uncalib) %>%mutate(target ="Total OAT",year = v_yr1_oat,group ="Model"))p3 <-ggplot() +geom_point(data = oat_target_uncalib_tbl,aes(x = year, y = target_val, color =factor(group),fill =factor(group))) +xlab("Year") +ylab("Total") +scale_color_brewer(palette ="Dark2", name ="") +scale_fill_brewer(palette ="Dark2", name ="") +theme(legend.position="bottom")plotly::ggplotly(p3)